﻿Imports ICtagControl.frmStartCompleteBase
Public Class clsDbResin

    Public Sub ConnectResinDB()
        With resin_Server
            g_iDBconnResult = ResinDBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver, .iPORT) 'ADD MIAO 2018/10/19
            If 1 <> g_iDBconnResult Then
                .szDrive = CStr(IIf("SQL Server" = .szDrive, "SQL Server", "SQL Server"))
                g_iDBconnResult = ResinDBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver, .iPORT) 'ADD MIAO 2018/10/19
            End If
        End With
    End Sub

    Public Function GetResinLimitTime(ByVal MaterialLot As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT TOP 1 UseLimitTime, UseableLimitDate "
        szSql &= "FROM [dbo].[LabelPrint_Data_out] "
        szSql &= "WHERE Lot_ID = '" & MaterialLot & "' "
        szSql &= "ORDER BY Bukatu_ID"

        Dim dt As DataTable = ResinDBacs.ExecuteSql(szSql, -1)

        If IsNothing(dt) Then
            GetResinLimitTime = New DataTable
        Else
            GetResinLimitTime = dt
        End If

    End Function
End Class
